<template>
  <u-form-grid :data="formGrid" :filterParams="hiddenQueryParams" ref=""></u-form-grid>
</template>

<script>
  import values from '../../utils/values';
  import axios from 'axios';

  export default {
    name: 'OrderBack',
    data () {
      var _this = this;
      return {
        hiddenQueryParams: {refundStatus: "待审核"},
        formGrid: {
          exportParams: ["orderNo", "payTime", "keyForLimit"],
          options: {
            autoLoad: true,
            version: 'v2',
            url: {
              page: "order/page",
              save: "order/saverefund",
            }
          },
          toolbar: {
            create: {
              show: false
            },
            delete: {
              show: false
            },
            groups: {
              show: true,
              export: {
                label: "导出全部",
                show: true,
                fileName: "退款订单数据",
                columns: [
                  {title: '订单编号', key: 'orderNo'},
                  {title: '车主名称', key: 'name'},
                  {title: '认证手机', key: 'mobileAudit'},
                  {title: 'VIN码', key: 'customerVin'},
                  {title: '经销商', key: 'targetDealer'},
                  {title: '车型', key: 'carType'},
                  {title: '商品名称', key: 'goodsName'},
                  {title: '微信支付订单号', key: 'transactionNo'},
                  {title: '唯一身份标识', key: 'keyForLimit'},
                  {title: '下订单时间', key: 'orderTime'},
                  {title: '支付时间', key: 'payTime'},
                  {title: '申请退款时间', key: 'applyRefundTime'},
                  {title: '订单状态', key: 'orderStatus'},
                  {title: '退款状态', key: 'refundStatus'},
                  {title: '申退理由', key: 'refundReason'}
                ]
              }
            },
            //关键字搜索框
            filter: {
              show: true,
              name: "keyWord",
              placeholder: "根据商品名称搜索"
            },
            superFilter: {
              show: true,
              label: "高级搜索",
              width: 500,
              columns: [
                {type: "text", label: "vin", name: "keyForLimit", icon: "plus", placeholder: "请填写vin"},
                {type: "text", label: "订单号", name: "orderNo", icon: "plus", placeholder: "请填写订单号"},
                {
                  type: "select",
                  label: "订单状态",
                  name: "orderStatus",
                  clearable: true,
                  filterable: false,
                  multiple: false,
                  data: [{
                    value: '未支付',
                    name: '未支付'
                  }, {
                    value: '支付中',
                    name: '支付中'
                  }, {
                    value: '已支付',
                    name: '已支付'
                  }, {
                    value: '已过期',
                    name: '已过期'
                  }
                  ]
                },
                {type: "date", label: "支付时间开始", name: "payTimeStart", required: false},
                {type: "date", label: "支付时间结束", name: "payTimeEnd", required: false}
              ],
              submit: {theme: "success", label: "查询", icon: "plus"}
            }
          },
          tips: {title: "申退审核", content: "根据条件：退款状态为待审核的订单"},
          form: {
            colNumber: 1,
            labelWidth: 100,
            modal: {
              title: "审核操作:请更改退款状态：退款成功 或 退款失败"
            },
            columns: [
              {label: "申退理由", type: "text", name: "refundReason", required: false, disabled: true},
              {
                label: "退款状态", type: "select", name: "refundStatus",
                items: [{"name": "退款成功", "value": "退款成功"}, {"name": "退款失败", "value": "退款失败"}],
                rule: {required: true, message: '请选择退款状态', trigger: 'change'}
              },
              {
                label: "退款资金来源", type: "select", name: "settle",
                items: [{"name": "可用余额退款", "value": "可用余额退款"}, {"name": "未结算资金退款", "value": '未结算资金退款'}],
                rule: {required: true, message: '请选择退款资金来源', trigger: 'blur'}
              },
              {label: "审核结果", type: "textarea", name: "refundAuditResult", required: true}
            ],
            submitBefore: function (data) {
              if (data.refundStatus === "待审核") {
                _this.$Notice.warning({
                  title: '提示',
                  desc: '请选择退款状态'
                });
                return false;
              }
              return true;
            }
          },
          table: {
            showCheckbox: false,
            operation: {
              primaryKey: "id",
              buttons: [{
                key: "view", show: false, "label": "详情", "theme": "text", click: (row, index, _this) => {
                  _this.optViewClick(row, index);
                }
              }, {
                key: "edit", show: true, "label": "审核退款", "theme": "primary", click: (row, index, _this) => {
                  _this.optEditClick(row, index);
                }
              }, {
                key: "delete", show: false, "label": "删除", "theme": "error", click: (row, index, _this) => {
                  _this.optDeleteClick(row, index);
                }
              }]
            },
            columns: [
              {title: '订单编号', key: 'orderNo'},
              {title: '车主名称', key: 'name'},
              {title: '认证手机', key: 'mobileAudit'},
              {title: 'VIN码', key: 'customerVin'},
              {title: '经销商', key: 'targetDealer'},
              {title: '车型', key: 'carType'},
              {title: '商品名称', key: 'goodsName'},
              {title: '微信支付订单号', key: 'transactionNo'},
              {title: '唯一身份标识', key: 'keyForLimit'},
              {title: '下订单时间', key: 'orderTime'},
              {title: '支付时间', key: 'payTime'},
              {title: '申请退款时间', key: 'applyRefundTime'},
              {title: '订单状态', key: 'orderStatus'},
              {title: '退款状态', key: 'refundStatus'},
              {title: '申退理由', key: 'refundReason'}
            ]
          }
        }
      }
    },
    methods: {}
  }

</script>
